<head>
  <%= javascript_include_tag :defaults %>

</head>
<h1>Nowy wynik badania</h1>

<% form_for(@exam_resoult) do |f| %>
  <p>
    Typ badania: <%=@exam_resoult.order_examination.examination_type.name %>
    <br/>
    Nr. zlecenia: <%=@exam_resoult.order_examination_id %>
  </p>
  <p>
    Płeć pacjenta: <%=@exam_resoult.order_examination.patient_data.sex.name %>
    <br/>
    Data urodzenia: <%=@exam_resoult.order_examination.patient_data.birth_date %>
  </p>
  <p>
    Komentarz do badania:<br/>
    <%= f.text_area :description %>
    <%= f.hidden_field :user_id %>
    <%= f.hidden_field :order_examination_id %>
  </p>
  <div id = "id">
    <p>
      Parametry:
    </p>
  </div>
  <table title="Parametry">
    <tr>
      <th>Nazwa</th>
      <th>Wynik</th>
      <th>Norma</th>
      <th>Komentarz</th>
    </tr>

    <%for param_resoult in @exam_resoult.param_resoults%>
      <tr>
        <%fields_for "temp_examination_resoult[param_resoult_attributes][]", param_resoult do |param_resoult_form| %>
          <td id = <%=param_resoult.param_norm_id%> >
          <p><%=param_resoult.param_norm.name%>
          </p>
          </td>
          <td><%= param_resoult_form.text_field :resoult,  :index => nil, :id=>("a_".concat(param_resoult.param_norm_id.to_s))%> </td>
          <%= observe_field(("a_"+param_resoult.param_norm_id.to_s),
                 :frequency => 0.25,
                 :update => param_resoult.param_norm_id.to_s,
                 :url => {:controller => :param_norms, :action => :check_param_valid },
                 :with => "'resoult='+ $('a_"+(param_resoult.param_norm_id).to_s+"').value + '&' + 'id='+ '"+param_resoult.param_norm_id.to_s+"'") %>

          <td><%=param_resoult.param_norm.min_norm%> -
            <%=param_resoult.param_norm.max_norm%>
            [<%=param_resoult.param_norm.unit%>]
          </td>
          <td><%= param_resoult_form.text_field :description, :index => nil%>
            <%= param_resoult_form.hidden_field :param_norm_id, :index => nil %>
            <%= param_resoult_form.hidden_field :id, :index => nil%>
          </td>
        <% end %>
      </tr>
    <% end %>
  </table>
  <p>
    <%= f.submit 'Utwórz' %>
  </p>
<% end %>